import React from "react";

// useSelector,useDispatch是redux新增的hooks
// useSelector是用于获取仓库的数据的
// useDispatch是用于改变仓库的数据的
import { useSelector, useDispatch } from "react-redux";

const Child2 = () => {
  const count = useSelector((state) => state.count);
  const age = useSelector((state) => state.age);
  const dispatch = useDispatch();

  return (
    <div>
      <h4>child2组件</h4>
      <p>count: {count}</p>
      <p>age: {age}</p>
      <button onClick={() => dispatch({ type: "add" })}>btn</button>
    </div>
  );
};

export default Child2;
